<?php $this->load->view('layout/header');?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">批量转账记录</h3>
            <?php echo breadcrumb(array('景区扫码转账记录')); ?>
        </div>
    </div>
    <?php echo execute_alert_message() ?>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-search"></i>搜索</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form class="form-horizontal form-search" action="<?php echo base_url('transferRecord/grid') ?>" method="get">
                        <div class="row-fluid">
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">转账编号</label>
                                    <div class="controls">
                                        <input type="text" name="transfer_id" value="<?php echo $this->input->get('transfer_id');?>" placeholder="转账编号" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <label class="control-label">转账时间</label>
                                <div class="controls form-search-time">
                                    <div class="input-append date date-picker">
                                        <input type="text" name="start_date" size="16" value="<?php echo $this->input->get('start_date');?>" class="m-wrap m-ctrl-medium date-picker date">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
                                    <div class="input-append date date-picker">
                                        <input type="text" name="end_date" size="16" value="<?php echo $this->input->get('end_date');?>" class="m-wrap m-ctrl-medium date-picker date">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-actions">
                            <button class="btn green" type="submit">搜索</button>
                            <button class="btn reset_button_search" type="button">重置条件</button>
                        </div>
                    </form>
                </div>
            </div>
            
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>列表</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body flip-scroll">
                    <div class="dataTables_wrapper form-inline">
                        <?php if ($all_rows > 0) :?>
                        <table class="table table-striped table-bordered table-hover" id="sample_1">
                            <thead class="flip-content">
                                <tr>
                                    <th width="30"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"></th>
                                    <th>交易编号</th>
                                    <th width="60">交易类型</th>
                                    <th width="120">交易总金额</th>
                                    <th width="120">请求总金额</th>
                                    <th width="120">成功总金额</th>
                                    <th width="120">交易状态</th>
                                    <th width="200">时间</th>
                                    <th>消息</th>
                                    <th width="70">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($page_list->result() as $item) : ?>
                                <tr>
                                    <td><input type="checkbox" class="checkboxes" value="1" ></td>
                                    <td><?php echo $item->transfer_id;?></td>
                                    <td><?php echo $transferType[$item->transfer_type];?></td>
                                    <td><?php echo '总金额：', $item->total_amount, '<br/>总笔数：', $item->total_num;?></td>
                                    <td><?php echo '请求金额：', $item->actual_amount, '<br/>请求笔数：', $item->actual_num;?></td>
                                    <td><?php echo '成功金额：', $item->success_amount, '<br/>成功笔数：', $item->success_num;?></td>
                                    <td>
                                        <?php if ($item->status == 3) : ?>
                                            <?php switch ($item->state) {
                                                case '2':
                                                    echo "成功下发文件到外联服务器<br/><a href='".site_url("transferRecord/batchCcbTransfer?transfer_id=".$item->transfer_id).'&token='. $token."' class='btn mini green'>发起交易</a>";
                                                    break;
                                                case '3':
                                                    echo '文件上传成功';
                                                    break;
                                                case '4':
                                                    echo "交易成功<br/><a href='".site_url("transferRecord/ccbBatchTransactionQuery/".$item->transfer_id).'?token='. $token."' class='btn mini green'>交易查询</a>";
                                                    break;
                                                case '5':
                                                    echo '交易成功';
                                                    break;
                                                default:
                                                    break;
                                            }?>
                                        <?php elseif ($item->status == 2) : ?>
                                            <?php switch ($item->state) {
                                                case '2':
                                                    echo '下发文件到外联服务器失败';
                                                    break;
                                                case '3':
                                                    echo '文件上传失败';
                                                    break;
                                                case '4':
                                                    echo "交易失败<br/><a href='".site_url("transferRecord/ccbBatchTransactionQuery/".$item->transfer_id).'?token='. $token."' class='btn mini green'>交易查询</a>";
                                                    break;
                                                case '5':
                                                    echo '交易失败';
                                                    break;
                                                default:
                                                    break;
                                        }?>
                                        <?php else : ?>
                                            <span class="btn mini green"><?php echo $transferStatus[$item->status]; ?></span>
                                            <?php if (in_array($item->status, array(4, 5, 6))) : ?>
                                                <a href='<?php echo site_url("transferRecord/ccbBatchTransactionQuery/".$item->transfer_id)."?token=". $token;?>' class="btn mini green">交易查询</a>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <?php echo '结算时间：', $item->start_time, '<br/> 至', $item->created_at,'<br/>交易时间：', $item->updated_at;?>
                                    </td>
                                    <td><?php echo $item->message;?></td>
                                    <td>
                                        <a href="<?php echo base_url('transferRecord/index?transfer_id='.$item->transfer_id); ?>" class="btn mini green">打款详细</a>
                                        <a href="<?php echo base_url('transferRecord/transferDetails/'.$item->transfer_id); ?>" class="btn mini green">交易详细</a>
                                    </td>
                                </tr>
                                <?php endforeach;?>
                            </tbody>
                        </table>
                        <div class="row-fluid">
                            <div class="span6">
                                <div class="dataTables_info">
                                    <span>当前第</span><span style="color: red"><?php echo $pg_now?></span>页
                                    <span>共</span><span style="color: red"><?php echo $all_rows?></span>条数据
                                    <span>每页显示20条 </span>
                                    <?php echo $pg_list ?>
                                </div>
                            </div>
                        </div>
                        <?php else: ?>
                            <div class="alert"><p>未找到数据。<p></div>
                        <?php endif ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="example" class="modal hide fade in" style="display: none; ">
    <form class="form-horizontal" action="<?php echo base_url('transferRecord/audit') ?>" method="post">
        <input type="hidden" name="withdraw_id" />
        <input type="hiiden" name="token" value="<?php echo $token; ?>">
        <div class="modal-header"><a class="close" data-dismiss="modal"></a><h3>转账审核</h3></div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label">审核</label>
                <div class="controls">
                    <label class="radio">
                        <div class="radio">
                            <span><input checked="checked"  type="radio" value="1" name="state"></span>
                        </div>
                        审核通过
                    </label>
                    <label class="radio">
                        <div class="radio">
                            <span><input type="radio" value="2" name="state"></span>
                        </div>
                        驳回
                    </label>
                </div>
            </div>
           <div class="control-group">
                <label class="control-label">备注</label>
                <div class="controls">
                    <textarea rows="3" name="describe" class="large m-wrap"></textarea>
                </div>
            </div>
        </div>
        <div class="modal-footer">
           <button class="btn green" type="submit"><i class="icon-ok"></i> 审核通过</button>
           <button class="btn " data-dismiss="modal" type="button">返回</button>
        </div>
    </form>
</div>

<?php $this->load->view('layout/footer');?>
<script type="text/javascript" >
$(function(){
    $('.virefy').click(function(){
        var id  = $(this).attr('data-id');
        var state = $(this).attr('data-state');
        $('#example input[name=withdraw_id]').val(id);
//      $('#ordereditvirefy').submit();
    });

    $('#example form').submit(function(){
        $('#example form button[type=submit]').attr('disabled', true);
    });

    $('a').click(function(){
        if ($(this).hasClass('disabled')){
            return false;
        } else {
            $(this).addClass('disabled');
            return true;
        }
    });
});
</script>